package com.koalac.ironman.net.pojo.request;

import java.io.Serializable;
import java.net.URLEncoder;

import android.content.Context;
import android.util.Log;

import com.koalac.ironman.cache.SysAppConfig;
import com.koalac.ironman.net.asynchttpclient.RequestParams;
import com.koalac.ironman.net.pojo.response.User;

/**
 * 客户端方法基类
 * @author liangzhenyu
 *
 */
public class ClientProtocolBase implements Serializable{
	protected String APIAddress = ""; //请求的地址
	protected String version = "";
	protected String auth = "";
	
	protected RequestParams map ;
	
	public ClientProtocolBase(){
		
	}
	
	public ClientProtocolBase(String APIAddress){
		this.APIAddress = APIAddress;
	}
	
	public ClientProtocolBase(String APIAddress,Context context){
		this.APIAddress = APIAddress;
	}
	
	public String getAPIddress(){
		return this.APIAddress;
	}
	
//	/**
//	 * 将参数转换为字符串，方便调试
//	 */
//	@Override
//	public String toString(){
//		return StrUtils.getFormatedMap(getArgus());
//	}

	/**
	 * 获取所有参数
	 * @return
	 */
	public RequestParams getArgus(Context context){
//		RequestParams baseParams =  new RequestParams();
		map = new RequestParams();
//		    Version = SysAppConfig.getInstance().getVerson(context)+"";
			auth = SysAppConfig.getInstance().getToken(context);
		Log.i("YYYYYYYYYYY=========", "====="+auth);
		if(auth!=null){
			map.put("m_auth",auth);
		}

		if(version != null){
			map.put("verson",version);
		}
		return map;
	}
//
//	/**
//	 * 请求API，POST参数到后台
//	 * @return
//	 */
//	public Response request() {
//		Map<String, String> postMap = getArgus();
//		Request request = new Request(APIAddress, postMap);
//		Response response ; 
//		try {
//			response = request.post();
//		} catch (IOException e) {
//			response = new Response();
//		}
//		return response;
//	}
//
//	/**
//	 * 请求API，POST参数和相片到后台
//	 * @return
//	 */
//	public Response upload(Map<String, String>fileMap) throws IllegalArgumentException, IllegalAccessException{
//		Map<String, String> postMap = getArgus();
//		Request request = new Request(APIAddress, postMap,fileMap);
//		Response response = null; 
//		try {
//			response = request.post();
//		} catch (IOException e) {
//
//		}
//		return response;
//	}

}
